package com.bangda.crm.service.impl;


import com.alibaba.druid.sql.visitor.functions.Isnull;
import com.bangda.crm.domain.CrmClientCondition;
import com.bangda.crm.mapper.CrmClientConditionMapper;
import com.bangda.crm.service.ICrmClientConditionService;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysUserService;
import org.apache.catalina.security.SecurityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-10-15
 */
@Service
public class CrmClientConditionServiceImpl implements ICrmClientConditionService
{
    @Autowired
    private CrmClientConditionMapper crmClientConditionMapper;

    @Autowired
    private ISysUserService userService;

    /**
     * 查询【请填写功能名称】
     * 
     * @param conditionId 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public CrmClientCondition selectCrmClientConditionByConditionId(Long conditionId)
    {
        return crmClientConditionMapper.selectCrmClientConditionByConditionId(conditionId);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param crmClientCondition 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<CrmClientCondition> selectCrmClientConditionList(CrmClientCondition crmClientCondition)
    {

        return crmClientConditionMapper.selectCrmClientConditionList(crmClientCondition);
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param crmClientCondition 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertCrmClientCondition(CrmClientCondition crmClientCondition)
    {
        SysUser sysUser = userService.selectUserByUserName(SecurityUtils.getUsername());
        if (StringUtils.isNotNull(sysUser.getNickName())){
            crmClientCondition.setCreateBy(sysUser.getNickName());
        }else {
            crmClientCondition.setCreateBy("该用户未设置名字");
        }
        crmClientCondition.setCreateTime(DateUtils.getNowDate());

        return crmClientConditionMapper.insertCrmClientCondition(crmClientCondition);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param crmClientCondition 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateCrmClientCondition(CrmClientCondition crmClientCondition)
    {
        crmClientCondition.setUpdateTime(DateUtils.getNowDate());
        return crmClientConditionMapper.updateCrmClientCondition(crmClientCondition);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param conditionIds 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteCrmClientConditionByConditionIds(Long[] conditionIds)
    {
        return crmClientConditionMapper.deleteCrmClientConditionByConditionIds(conditionIds);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param conditionId 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteCrmClientConditionByConditionId(Long conditionId)
    {
        return crmClientConditionMapper.deleteCrmClientConditionByConditionId(conditionId);
    }
}
